package cn.edu.cdu.group4nb.service.impl;

import cn.edu.cdu.group4nb.mapper.EducationMapper;
import cn.edu.cdu.group4nb.mapper.EmployerMapper;
import cn.edu.cdu.group4nb.mapper.RecordMapper;
import cn.edu.cdu.group4nb.mapper.UserInfMapper;
import cn.edu.cdu.group4nb.po.Education;
import cn.edu.cdu.group4nb.po.UserInf;
import cn.edu.cdu.group4nb.po.UserInfExample;
import cn.edu.cdu.group4nb.service.EmployerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class EmployerServiceImpl implements EmployerService {
    @Autowired
    private EmployerMapper employerMapper;
    @Autowired
    private UserInfMapper userInfMapper;
    @Autowired
    private EducationMapper educationMapper;
    @Override
    public List<Map<String, Object>> selectNormalEmp() {

        return employerMapper.selectNormalEmp();
    }
    @Override
    public Map<String, Integer> getCountGender() {
        UserInfExample userInfExample = new UserInfExample();
        UserInfExample.Criteria criteria = userInfExample.createCriteria();
        criteria.andGithuburlEqualTo("男");
        int countAllGender = userInfMapper.countByExample(null);
        int countMale = userInfMapper.countByExample(userInfExample);
        Map<String,Integer> map=new HashMap<>();
        map.put("male",countMale);
        map.put("female",countAllGender-countMale);
        map.put("allgender",countAllGender);
        return map;
    }

    @Override
    public Map<String, Integer> getSalaryCount() {
        int userCount= userInfMapper.countByExample(null);
        int salaryCount=employerMapper.getSalaryCount();
        Map<String,Integer> map=new HashMap<>();
        map.put("allUser",userCount);
        map.put("salaryCount",salaryCount);
        return map;

    }


    @Override
    public Map<String, Integer> getEducationCount() {

        int userCount= userInfMapper.countByExample(null);
        List<Education> educations = educationMapper.selectByExample(null);
        Map<String,Integer> map=new HashMap<>();

        for (Education education:educations ) {
            map.put(education.getEducationDesc(),  employerMapper.getEducationCount(education.getEducationDesc()));
        }
        return map;

    }
}
